@extends('layouts.appDomain')

@section('content')
<div class="container py-5">
    <div class="row justify-content-center">
        <div class="col-12">
			<div class="text-right mb-2"><a href="/user/recharge">充值</a> <a href="/user/moneyLog">记录</a></div>
            <div class="card panel mb-4">
                <div class="card-header">积分充值</div>

                <div class="card-body">
                	<form action="{{url('/user/rechargeDo')}}" method="post" onsubmit="return checkForm();">
                		@csrf
                		<input type="hidden" name="server_id" value="{{$server->id}}">
                		<input type="hidden" name="manager_id" value="{{$server->user_id}}">
                		<input type="hidden" name="user_id" value="{{json_decode( session('player'))->id}}">
	                	<div class="row col-12">
							<div class="col-md-6">
								<div class="input-group mt-2">
									<div class="input-group-prepend">
										<div class="input-group-text">请输入充值金额</div>
									</div>
									<input type="number" name="money" id="money" min="1" step="1" max="100000" class="form-control" >
									<div class="input-group-append">
										<div class="input-group-text">元</div>
									</div>
								</div>
							</div>

							<div class="col-md-6">
								<div class="input-group mt-2">
									<div class="input-group-prepend">
										<div class="input-group-text">增加积分</div>
									</div>
									<input type="text" class="form-control" id="price" readonly>
								</div>
							</div>

	                	</div>
	                	<div class="text-center mt-5">

							<div class="custom-control custom-radio custom-control-inline">
								<input type="radio" id="customRadioInline1" name="pay_way" value="1" class="custom-control-input" checked>
								<label class="custom-control-label" for="customRadioInline1">微信支付</label>
							</div>
							<div class="custom-control custom-radio custom-control-inline">
								<input type="radio" id="customRadioInline2" name="pay_way" value="2" class="custom-control-input">
								<label class="custom-control-label" for="customRadioInline2">支付宝支付</label>
							</div>

	                	</div>

	                	<div class="text-center mt-5">
	                		<button class="btn btn-info" type="submit">立即充值</button>
	                	</div>
					</form>
					<input type="hidden" value="{{config('conf.oneRMBToMoney')}}" id="rate">
                </div>
            </div>
        </div>
    </div>
</div>

@endsection

@section('script')

	<script type="text/javascript">
        $('#money').on('keyup change',function(){
			var rate = $('#rate').val();
            $(this).val($(this).val().replace(/\D|^0/g,''));
			var price = $(this).val() * rate;
            $('#price').val(price);
        });
        function checkForm(){
            var money = $('#money').val();
            if (money <= 0) {
                alert('请输入充值金额');
                return false;
            }
        }
	</script>
@endsection

